// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from "axios";
import ElementUI from 'element-ui';
Vue.configproductionTip = false;


// 绑定到原型
Vue.prototype.$axios = axios;
Vue.use(ElementUI);
import 'element-ui/lib/theme-chalk/index.css';
//设置默认的 api 域名
axios.defaults.baseURL = "http://111.230.181.206:3000"

// 路由守卫
router.beforeEach((to,from,next)=>{
  if(to.path!='/login'){
    const token=localStorage.getItem('token')
    if(!token){
      router.push('/login')
    }else{
      next()
    }
  }else{
    next()
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
